<?php
class ImageFilesValidatorSchema extends sfValidatorSchema
{
    public function __construct($messages = array())
    {
        $this->addMessage('empty', 'Must set at least one file to upload.');

        $options = array();

        parent::__construct(null, $options, $messages);
    }

    protected function doClean($values)
    {
        if (null === $values)
        {
            $values = array();
        }

        if (!is_array($values))
        {
            throw new InvalidArgumentException('You must pass an array parameter to the clean() method');
        }

        foreach($values as $key => $value)
        {
            if ($value['file'] == '')
            {
                unset($values[$key]);
            }
        }

        if(!count($values))
        {
            throw new sfValidatorError($this, 'empty');
        }

        return $values;
    }

}